package org.shilong.UI.party;

import org.shilong.UI.R;
import org.shilong.ViewUtility.PariesTitleProvider;
import org.taptwo.android.widget.TitleFlowIndicator;
import org.taptwo.android.widget.ViewFlow;

import android.app.ActivityGroup;
import android.app.LocalActivityManager;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.PopupWindow;

/**
 * 关于我的聚会和我参加过的聚会的屏幕
 */
public class PartiesOfMineFrame extends ActivityGroup {

	private LocalActivityManager manager;

	private TitleFlowIndicator indicator;

	private ViewFlow viewFlow;

	private Class<?>[] clsArr;


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

		setContentView( R.layout.layout_manage_paries_content );

		initObjects();

		initViews();


	}

	private void initObjects() {

		manager = getLocalActivityManager();

		clsArr = new Class<?>[]{ PariesCreateByMeFrame.class, MyPariesWhichITakePartInFrame.class };
	}


	private void initViews(){


		indicator = (TitleFlowIndicator)this.findViewById( R.id.manage_party_viewflowindic );

		indicator.setTitleProvider( new PariesTitleProvider() );

		viewFlow = ( ViewFlow )this.findViewById( R.id.manage_party_viewflow );

		viewFlow.setFlowIndicator(indicator);

		viewFlow.setAdapter( new MAdapter( clsArr ) );

	}

	private class MAdapter extends BaseAdapter{

		private Class<?>[] arr;

		public MAdapter( Class<?>[] arr ){

			this.arr = arr;

		}

		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return arr.length;
		}

		@Override
		public Object getItem(int arg0) {
			// TODO Auto-generated method stub
			return arr[arg0];
		}

		@Override
		public long getItemId(int arg0) {
			// TODO Auto-generated method stub
			return arg0;
		}

		@Override
		public View getView(int arg0, View arg1, ViewGroup arg2) {

			View view = null;

			Intent mIntent = new Intent();

			mIntent.setClass( PartiesOfMineFrame.this, arr[arg0] );

			view = manager.startActivity("iddd"+Math.random() , mIntent ).getDecorView();

			return view;
		}

	}
}
